<?php

#### General PHP Configuration
ini_set('error_reporting', E_ALL);// & ~E_NOTICE);
setlocale(LC_CTYPE, 'de_DE.utf-8');
ini_set('log_errors', true);
ini_set('error_log', realpath(dirname(__FILE__).'/../logs/error.log'));
ini_set('display_errors', true);
ini_set('magic_quotes_gpc', false);
ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.realpath(dirname(__FILE__).'/../library/'));

/**
 * Add autoload support for Zend Framework compatible classes
 */
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();


Marjory_Service::$logTarget = realpath('../logs/error.log');
// Set up a logging filter
Marjory_Service::getLog()->addFilter(new Zend_Log_Filter_Priority(Zend_Log::DEBUG));


// Do some common configuration tasks
if (file_exists('../application/config.php')) {
    require '../application/config.php';
}

// set it in a controller
$ctrl = Zend_Controller_Front::getInstance();
$ctrl->setParam('noViewRenderer', true);
$r = $ctrl->getRouter();
/*
$restAction = array("controller" => "rest", "action" => "service");
$r->addRoute('restService', new Zend_Controller_Router_Route('rest/:method/*', $restAction));
$r->addRoute('restSearch',  new Zend_Controller_Router_Route('rest/search/:phrase', $restAction));
*/

// set controller directory and dispatch
$ctrl->setControllerDirectory(realpath('../application/controllers'));
$ctrl->returnResponse(true);

$response = $ctrl->dispatch();

/*********** SET TO FALSE ON PRODUCTION WEBSITES !!!!!!! ***********/
$response->renderExceptions(true);
/*******************************************************************/

echo $response;
